package com.arpa.oms.service;

import com.arpa.oms.domain.dto.OmsInventoryDTO;
import com.arpa.oms.domain.entity.OmsInventory;
import com.arpa.oms.domain.vo.OmsInventoryVO;
import com.baomidou.mybatisplus.extension.service.IService;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;


/**
 * <p>
 * OMS库存服务类
 * </p>
 *
 * @author LEO
 * @since 2020-10-22
 */
public interface IOmsInventoryService extends IService<OmsInventory> {


    /**
     * 从库存中获取相同库存，如果没有则返回空
     * @param goodsCode
     * @param warehouseCode
     * @param shipmentCode
     * @return
     */
    OmsInventory hasSameInventory(String goodsCode, String warehouseCode, String shipmentCode);

    /**
     * 调整库存数量，正数为加库存，负数为减库存
     * @param code
     * @param adjustQuantity
     */
    void adjustQuantity(String code, BigDecimal adjustQuantity);

    /**
     * 调整库存数量（和价格），正数为加库存（和价格），负数为减库存（和价格）
     * @param code
     * @param adjustQuantity
     */
    void adjustQuantityAndPrice(String code, BigDecimal adjustQuantity);

    /**
     * 调整库存占用数量，正数为加库存，负数为减库存
     * @param code
     * @param adjustQuantity
     */
    void adjustUseQuantity(String code, BigDecimal adjustQuantity);

    /**
     * 锁可用库存
     * @param warehouseCode
     * @param goodsCode
     * @param goodsName
     * @param shipmentCode
     * @param lockQuantity
     */
    void lockUsefulInventory(String warehouseCode, String goodsCode, String goodsName, String shipmentCode, BigDecimal lockQuantity);


    /**
     * 更新oms的不可用库存数量，用于wms各种库存变动操作后，同步oms的不可用库存数量
     * @param warehouseCode
     * @param shipmentCode
     * @param goodsCode
     * @param contUseQuantity
     */
    void refreshOmsContUseQuantity(String warehouseCode, String shipmentCode, String goodsCode, BigDecimal contUseQuantity);


    OmsInventoryVO queryListSum(OmsInventoryDTO dto);

    List<OmsInventoryVO> queryList(OmsInventoryDTO dto);

    List<Map<String, Object>> inventoryCount(String shipmentCode, List<String> warehouseCodes);

    /**
     * 释放占用库存
     * @param warehouseCode
     * @param goodsCode
     * @param shipmentCode
     * @param lockQuantity
     */
    void releaseOccupiedInventory(String warehouseCode, String goodsCode, String shipmentCode, BigDecimal lockQuantity);
}
